package cn.simon.free.redis.mq.core;

import cn.simon.free.redis.mq.component.RedisMessageDelayRoSupport;
import cn.simon.free.redis.mq.component.RedisMessageNormalRoSupport;
import cn.simon.free.redis.mq.component.RedisMessageSupport;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * redis,消息队队列,顶级抽象类
 * 就是存储一些不变属性在这里
 *
 * @author simon
 * @date 2021/7/1 14:17
 * @copyright:
 * @modifier
 * @motto a no talent, people who have to study hard
 */
public class AbstractRedisMessage implements ApplicationContextAware {

    protected final ObjectMapper mapper = new ObjectMapper();
    protected RedisMessageSupport redisMessageSupport;
    protected RedisMessageDelayRoSupport redisMessageDelayRoSupport;
    protected RedisMessageNormalRoSupport redisMessageNormalRoSupport;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        redisMessageSupport = applicationContext.getBean(RedisMessageSupport.class);
        redisMessageDelayRoSupport = applicationContext.getBean(RedisMessageDelayRoSupport.class);
        redisMessageNormalRoSupport = applicationContext.getBean(RedisMessageNormalRoSupport.class);
    }
}
